from src.modules import db
from datetime import datetime

class HistoryRecord(db.Model):
    __tablename__ = 't_history_record'
    id = db.Column(db.String(50), primary_key = True)
    source = db.Column(db.String(20))
    pattern = db.Column(db.String(20))
    name = db.Column(db.String(100))
    create_time = db.Column(db.DateTime, default = lambda: datetime.now())

    def to_dict(self):
        d = {i.name: getattr(self, i.name) for i in self.__table__.columns}
        return d
